package com.teen9g.infoplatformserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teen9g.entity.TeachingBuilding;
import com.teen9g.userVO.TeachingBuildingUserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TeachingBuildingMapper extends BaseMapper<TeachingBuilding> {
    List<TeachingBuilding> getpage(@Param("buildingId") Integer buildingId,
                                   @Param("roomNumber") String roomNumber);

    @Select("select * from teaching_building order by content_view desc limit #{topCount}")
    List<TeachingBuilding> selectTopTotalViewTeachingBuildings(@Param("topCount") int topCount);

    @Update("update teaching_building set content_view = content_view + #{increment} where content_id = #{contentId}")
    void updateViewCount(@Param("contentId") Integer contentId, @Param("increment") Integer increment);

    @Update("update teaching_building set " +
            "content_comment_count = content_comment_count + #{updateCount} " +
            "where content_id = #{relatedId}")
    void updateCommentCount(@Param("relatedId") Integer relatedId, @Param("updateCount") Integer updateCount);

    List<TeachingBuildingUserVO> getpageUser(String contentAuthor);

}
